1 package edu.jiangxin.apktoolbox.help.settings; 2 3 import edu.jiangxin.apktoolbox.swing.extend.EasyChildTabbedPanel; 4 import edu.jiangxin.apktoolbox.utils.Constants; 5 6 import javax.swing.*; 7 import java.io.Serial; 8 9 public class AlwaysOnTopPanel extends EasyChildTabbedPanel { 10 @Serial 11 private static final long serialVersionUID = 1L; 12 13 private JPanel optionPanel; 14 15 @Override 16 public void createUI() { 17 BoxLayout boxLayout = new BoxLayout(this, BoxLayout.Y_AXIS); 18 setLayout(boxLayout); 19 20 createOptionPanel(); 21 add(optionPanel); 22 23 add(Box.createVerticalStrut(15 * Constants.DEFAULT_Y_BORDER)); 24 } 25 26 private void createOptionPanel() { 27 optionPanel = new JPanel(); 28 optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS)); 29 30 JLabel typeLabel = new JLabel("Always on top:"); 31 JCheckBox alwaysOnTopCheckBox = new JCheckBox(); 32 alwaysOnTopCheckBox.setSelected(conf.getBoolean("always.on.top", false)); 33 alwaysOnTopCheckBox.addActionListener(e -> { 34 conf.setProperty("always.on.top", alwaysOnTopCheckBox.isSelected()); 35 getFrame().setAlwaysOnTop(alwaysOnTopCheckBox.isSelected()); 36 SwingUtilities.updateComponentTreeUI(getFrame()); 37 getFrame().refreshSizeAndLocation(); 38 }); 39 40 optionPanel.add(typeLabel); 41 optionPanel.add(Box.createHorizontalStrut(Constants.DEFAULT_X_BORDER)); 42 optionPanel.add(alwaysOnTopCheckBox); 43 } 44 }